package com.xyz.study.design_mode.p_mediator.mode;

/**
 * 角色：ConcreteMediator 仲裁者
 *
 * @author XYZ
 * @version 1.0
 * @since 2023/1/11
 */
public class Mother implements Mediator{
    private final Colleague xiaoMing;
    private final Colleague xiaoHong;

    public Mother(Colleague xiaoMing, Colleague xiaoHong) {
        this.xiaoMing = xiaoMing;
        this.xiaoHong = xiaoHong;
    }


    @Override
    public void colleagueChanged(Colleague colleague) {
        if (colleague.name().equals(xiaoHong.name())) {
            xiaoMing.controlColleague();
            return;
        }
        if (colleague.name().equals(xiaoMing.name())) {
            xiaoHong.controlColleague();
            return;
        }
    }
}
